package com.lc.bean;

import com.lc.utils.PropertiesUtils;

/**
 * 功能：加载匹配文件
 * 作者：lc
 * 日期：2024/6/12 11:47
 */
public class Constants {
    public static Boolean IGNORE_TABLE_PREFIX;
    public static String SUFFIX_BEAN_QUERY;
    public static String PATH_BASE;
    public static String SUFFIX_TABLE_QUERY_FUZZY;
    public static String SUFFIX_TABLE_QUERY_START;
    public static String SUFFIX_TABLE_QUERY_END;
    public static String SUFFIX_MAPPER;
    // 需要忽略的属性
    public static String IGNORE_BEAN_TOJSON_FIELD;
    public static String IGNORE_BEAN_TOJSON_EXPRESSION;
    public static String IGNORE_BEAN_TOJSON_CLASS;
    // 是否删除行数据
    public static Boolean IGNORE_COLUMN_DATA;
    // 日期序列化  反序列化
    public static String BEAN_DATE_FORMAT_EXPRESSION;
    public static String BEAN_DATE_FORMAT_CLASS;
    public static String BEAN_DATE_UNFORMAT_EXPRESSION;
    public static String BEAN_DATE_UNFORMAT_CLASS;
    public static String PATH_JAVA = "java";
    public static String PATH_RESOURCES = "resources";
    public static String PATH_PO;
    public static String PATH_QUERY;
    public static String PACKAGE_BASE;
    public static String PACKAGE_PO;
    public static String PACKAGE_QUERY;
    public static String PACKAGE_UTILS;
    public static String PACKAGE_ENUMS;
    public static String PACKAGE_MAPPER;
    public static String PATH_ENUMS;
    public static String PATH_UTILS;
    public static String PATH_MAPPER;
    public static String PATH_MAPPER_XML;
    // 业务层地址
    public static String PACKAGE_SERVICE;
    public static String PACKAGE_SERVICEIMPL;
    // 业务层路径
    public static String PATH_SERVICE;
    public static String PATH_SERVICEIMPL;
    public static String PACKAGE_VO;
    public static String PATH_VO;
    // 控制层
    public static String PACKAGE_EXCEPTION;
    public static String PATH_EXCEPTION;
    public static String PACKAGE_CONTROLLER;
    public static String PATH_CONTROLLER;

    public final static String[] SQL_DATE_TIME_TYPES = new String[]{"datetime", "timestamp"};
    public final static String[] SQL_DATE_TYPES = new String[]{"date", "time"};
    public final static String[] SQL_DECIMAL_TYPE = new String[]{"decimal", "double", "float"};
    public final static String[] SQL_STRING_TYPE = new String[]{"char", "varchar", "text", "mediumtext", "longtext"};
    public final static String[] SQL_INTEGER_TYPE = new String[]{"int", "tinyint", "tinyint unsigned"};
    public final static String[] SQL_LONG_TYPE = new String[]{"bigint"};
    public final static String[] SQL_BIGINTEGER_TYPE = new String[]{"bigint unsigned"};

    static {
        IGNORE_BEAN_TOJSON_FIELD = PropertiesUtils.getString("ignore.bean.tojson.field");
        IGNORE_BEAN_TOJSON_EXPRESSION = PropertiesUtils.getString("ignore.bean.tojson.expression");
        IGNORE_BEAN_TOJSON_CLASS = PropertiesUtils.getString("ignore.beam.tojson.class");
        // 是否真正删除
        IGNORE_COLUMN_DATA = Boolean.valueOf(PropertiesUtils.getString("ignore.column.data"));
        // 查询后缀
        SUFFIX_TABLE_QUERY_FUZZY = PropertiesUtils.getString("suffix.table.query.fuzzy");
        SUFFIX_TABLE_QUERY_START = PropertiesUtils.getString("suffix.table.query.start");
        SUFFIX_TABLE_QUERY_END = PropertiesUtils.getString("suffix.table.query.end");
        SUFFIX_MAPPER = PropertiesUtils.getString("suffix.mapper");

        // 日期序列化  反序列化
        BEAN_DATE_FORMAT_EXPRESSION = PropertiesUtils.getString("bean.date.format.expression");
        BEAN_DATE_FORMAT_CLASS = PropertiesUtils.getString("bean.date.format.class");
        BEAN_DATE_UNFORMAT_EXPRESSION = PropertiesUtils.getString("bean.date.unformat.expression");
        BEAN_DATE_UNFORMAT_CLASS = PropertiesUtils.getString("bean.date.unformat.class");
        IGNORE_TABLE_PREFIX = Boolean.valueOf(PropertiesUtils.getString("ignore.table.prefix"));
        SUFFIX_BEAN_QUERY = PropertiesUtils.getString("suffix.table.query");

        // base
        PACKAGE_BASE = PropertiesUtils.getString("package.base");
        // PO
        PACKAGE_PO = PACKAGE_BASE + "." + PropertiesUtils.getString("package.po");
        PACKAGE_UTILS = PACKAGE_BASE + "." + PropertiesUtils.getString("package.utils");
        PACKAGE_ENUMS = PACKAGE_BASE + "." + PropertiesUtils.getString("package.enums");
        PACKAGE_MAPPER = PACKAGE_BASE + "." + PropertiesUtils.getString("package.mappers");
        PACKAGE_VO = PACKAGE_BASE + "." + PropertiesUtils.getString("package.vo");
        // 业务层
        PACKAGE_SERVICE = PACKAGE_BASE + "." + PropertiesUtils.getString("package.service");
        PACKAGE_SERVICEIMPL = PACKAGE_BASE + "." + PropertiesUtils.getString("package.serviceImpl");

        // 控制层
        PACKAGE_EXCEPTION = PACKAGE_BASE + "." + PropertiesUtils.getString("package.exception");
        PACKAGE_CONTROLLER = PACKAGE_BASE + "." + PropertiesUtils.getString("package.controller");
        // query
        PACKAGE_QUERY = PACKAGE_BASE + "." + PropertiesUtils.getString("package.query");
        // 基本路径
        PATH_BASE = PropertiesUtils.getString("path.base");
        PATH_BASE = PATH_BASE + PATH_JAVA;
        PATH_RESOURCES = PropertiesUtils.getString("path.base") + PATH_RESOURCES;
        // 写入磁盘路径
        PATH_PO = (PATH_BASE + "/" + PACKAGE_PO).replace(".", "/");
        PATH_UTILS = (PATH_BASE + "/" + PACKAGE_UTILS).replace(".", "/");
        PATH_ENUMS = (PATH_BASE + "/" + PACKAGE_ENUMS).replace(".", "/");
        PATH_QUERY = (PATH_BASE + "/" + PACKAGE_QUERY).replace(".", "/");
        PATH_MAPPER = (PATH_BASE + "/" + PACKAGE_MAPPER).replace(".", "/");
        PATH_MAPPER_XML = (PATH_RESOURCES + "/" + "mappers").replace(".", "/");
        PATH_SERVICE = (PATH_BASE + "/" + PACKAGE_SERVICE).replace(".", "/");
        PATH_SERVICEIMPL = (PATH_BASE + "/" + PACKAGE_SERVICEIMPL).replace(".", "/");
        PATH_VO = (PATH_BASE + "/" + PACKAGE_VO).replace(".", "/");
        PATH_EXCEPTION = (PATH_BASE + "/" + PACKAGE_EXCEPTION).replace(".", "/");
        PATH_CONTROLLER = (PATH_BASE + "/" + PACKAGE_CONTROLLER).replace(".", "/");

    }

    public static void main(String[] args) {
        System.out.println(PACKAGE_MAPPER);
        System.out.println(PATH_RESOURCES);
        System.out.println(PATH_MAPPER_XML);

    }
}
